package jnpf.service;

import jnpf.entity.utils.PageVO;
import jnpf.mapper.MeetingMapper;
import jnpf.model.meeting.dto.MeetingDTO;
import jnpf.model.meeting.vo.MeetingVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.text.SimpleDateFormat;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class MeetingService {

    @Autowired
    private MeetingMapper meetingMapper;

    public PageVO listMeeting(MeetingDTO meetingDTO) {
        SimpleDateFormat sdf16 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<MeetingVO> meetingVO = meetingMapper.listMeeting(meetingDTO);
        meetingVO.stream().map(vo -> {
            vo.setStringTime(sdf16.format(vo.getStartTime()));
            return vo;
        }).collect(Collectors.toList());

        int total = meetingMapper.countMeeting(meetingDTO);
        PageVO vo = new PageVO();
        vo.setTotal(total);
        vo.setList(meetingVO);
        return vo;
    }
}


